package com.canaan.business.controller.pc.inOutStock;

import com.canaan.business.domain.inOutStock.WmsPickingRecord;
import com.canaan.business.service.inOutStock.IWmsPickingRecordService;
import com.canaan.common.annotation.Log;
import com.canaan.common.core.controller.BaseController;
import com.canaan.common.core.domain.AjaxResult;
import com.canaan.common.core.page.TableDataInfo;
import com.canaan.common.enums.BusinessType;
import com.canaan.common.utils.poi.ExcelUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 拣货记录Controller
 *
 * @author ruoyi
 * @date 2022-12-20
 */
@Api(tags = "拣货记录")
@RestController
@RequestMapping("/inOutStock/pickingRecord")
public class WmsPickingRecordController extends BaseController
{
    @Resource
    private IWmsPickingRecordService wmsPickingRecordService;

    /**
     * 查询拣货记录列表
     */
    @ApiOperation(value = "查询拣货记录列表")
    @GetMapping("/list")
    public TableDataInfo list(WmsPickingRecord wmsPickingRecord)
    {
        startPage();
        List<WmsPickingRecord> list = wmsPickingRecordService.selectWmsPickingRecordList(wmsPickingRecord);
        return getDataTable(list);
    }

    /**
     * 导出拣货记录列表
     */
    @ApiOperation(value = "导出拣货记录列表")
    @Log(title = "拣货记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WmsPickingRecord wmsPickingRecord)
    {
        List<WmsPickingRecord> list = wmsPickingRecordService.selectWmsPickingRecordList(wmsPickingRecord);
        ExcelUtil<WmsPickingRecord> util = new ExcelUtil<WmsPickingRecord>(WmsPickingRecord.class);
        util.exportExcel(response, list, "拣货记录数据");
    }

    /**
     * 获取拣货记录详细信息
     */
    @ApiOperation(value = "获取拣货记录详细信息")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(wmsPickingRecordService.selectWmsPickingRecordById(id));
    }

    /**
     * 新增拣货记录
     */
    @ApiOperation(value = "新增拣货记录")
    @Log(title = "拣货记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WmsPickingRecord wmsPickingRecord)
    {
        return toAjax(wmsPickingRecordService.insertWmsPickingRecord(wmsPickingRecord));
    }

    /**
     * 修改拣货记录
     */
    @ApiOperation(value = "修改拣货记录")
    @Log(title = "拣货记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WmsPickingRecord wmsPickingRecord)
    {
        return toAjax(wmsPickingRecordService.updateWmsPickingRecord(wmsPickingRecord));
    }

    /**
     * 删除拣货记录
     */
    @ApiOperation(value = "删除拣货记录")
    @Log(title = "拣货记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(wmsPickingRecordService.deleteWmsPickingRecordByIds(ids));
    }
}
